﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Web.Routing;
//using TCL.EO;

//namespace TCL.FUNC
//{
//    public class URLRewriter
//    {
//        public static Boolean bSyncMapUrl;

//        public static void RegisterRoutes(object source, System.Timers.ElapsedEventArgs e)
//        {
//            try
//            {
//                if (bSyncMapUrl)
//                {
//                    String sRootPath = System.Configuration.ConfigurationSettings.AppSettings["RawUrl_RootPath"];
//                    String sFilePath = System.Configuration.ConfigurationSettings.AppSettings["RawUrl_FilePath"];
//                    List<URLRewriterEO> lstMapUrl = new List<URLRewriterEO>();
//                    String sFileContent = Folder_File.ReadFile(sFilePath, sRootPath);
//                    if (!String.IsNullOrEmpty(sFileContent))
//                    {
//                        object temp = JsonEx.Json2ListObject(sFileContent, lstMapUrl.GetType());
//                        if (temp != null)
//                            lstMapUrl = (List<URLRewriterEO>)temp;
//                    }
//                    if (lstMapUrl != null && lstMapUrl.Count > 0)
//                    {
//                        RouteTable.Routes.Clear();
//                        foreach (var item in lstMapUrl)
//                        {
//                            if (Convert.ToString(item.physicalFile).StartsWith("~/"))
//                                RouteTable.Routes.MapPageRoute(item.routeName, item.routeUrl, item.physicalFile);
//                        }
//                    }
//                    bSyncMapUrl = false;

//                    //RouteTable.Routes.MapPageRoute("Home", "", "~/Default.aspx");
//                    //RouteTable.Routes.MapPageRoute("About", "gioi-thieu.html", "~/About.aspx");
//                    //RouteTable.Routes.MapPageRoute("Category", "danh-muc/{category}/{page}", "~/Category.aspx");
//                    //RouteTable.Routes.MapPageRoute("Category2", "danh-muc/{category}", "~/Category.aspx");
//                    //RouteTable.Routes.MapPageRoute("Category3", "danh-muc", "~/Category.aspx");
//                    //RouteTable.Routes.MapPageRoute("Topic", "bai-viet/{Title}.{Id}.html", "~/Topic.aspx");
//                }
//            }
//            catch
//            {
//            }
//        }

//    }
//}
